package com.frxuexi.myroom.repository

import com.frxuexi.lib_base.room.Leave
import com.frxuexi.lib_base.room.User
import com.frxuexi.lib_base.room.UserDao
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

@OptIn
class UserRepository @Inject constructor(private val userDao: UserDao) {

    fun register(user: User):Flow<Long>{
        return flow { emit(userDao.register(user)) }
    }

    fun login(uname:String,upass:String,role:String):Flow<User>{
        return flow { emit(userDao.login(uname, upass, role)) }
    }

    fun updataLogin(user: User):Flow<Int>{
        return flow { emit(userDao.updataLogin(user)) }
    }

    fun getLogin():Flow<List<User>>{
        return flow { emit(userDao.getLogin()) }
    }
}